Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect: Turn on waf module by default and add UI control for automatic rules #27663

Conversation

dkmyta
Copy link
Contributor

@dkmyta dkmyta commented Nov 29, 2022

Description

Adds to the Protect UI, the ability to toggle on automatic and manual rules independent of one another.

Changes proposed in this Pull Request:

  • The waf module is now enabled on plugin activation.
  • The firewall settings UI now expects to be able to use the waf package, and displays an error and prompt to re-enable the module if it is disabled (see screenshots).
  • The module toggle in the firewall settings UI has been updated to control the jetpack_waf_automatic_rules option instead of toggling the module.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?

Jetpack product discussion

  • 1201069996155224-as-1203279663034183

Does this pull request change what data or activity we track or use?

  • No

Testing instructions:

  • Checkout this branch
  • Load your Jurassic Tube
  • Validate that the waf module is disabled.
  • Activate Protect
  • Validate that the waf module is enabled.
  • Proceed to Protect admin page and select the Firewall tab
  • Verify that automatic and manual rules are disabled by default.
  • Enable Automatic rules
  • Validate that a request is blocked (i.e. ?foo=<script>)
  • Enable Manual rules
  • Verify that a new manual rules settings section is loaded in place of the primary section
  • Select Edit manual rules
  • Add and/or remove rules and ensure that they are appropriately set
  • Manually disable the waf module, and ensure the firewall settings screen matches the screenshot below.
  • Ensure no regression in application functionality

Screenshots

Screen Shot 2022-12-12 at 11 26 45 AM

Module disabled:

Screen Shot 2022-12-12 at 11 35 38 AM

nateweller and others added 28 commits November 21, 2022 10:17
* Add hook for interfacing with WAF data

* [not verified] Add firewall-header component folder structure

* [not verified] Apply header component code and styling

* [not verified] Remove unneeded comments

* [not verified] Update hasRequiredPlan check to useProtectData

* [not verified] Fix typo

* Add FirewallHeader component stories and improve portability

* Add useWafData hook placeholder for moduleIsEnabled check

* [not verified] Remove isModuleEnabled property in favor of currently available WAF data

* [not verified] Remove console logging

* [not verified] Add upgrade functionality to button

* [not verified] Add Popover component for upgrade info

* Fix styling issues

* Create ConnectedFirewallHeader component and move all logic out of FirewallPage

* Improve code efficiency

* Update FirewallHeader status check, and checkout flow redirect URL

* changelog

* [not verified] Remove changelog entry

* Change FirewallUrl to firewallUrl

Co-authored-by: Nate Weller <nate.weller@automattic.com>
* Add hook for interfacing with WAF data

* [not verified] Add firewall-header component folder structure

* [not verified] Apply header component code and styling

* [not verified] Remove unneeded comments

* [not verified] Update hasRequiredPlan check to useProtectData

* [not verified] Fix typo

* Add FirewallHeader component stories and improve portability

* Add useWafData hook placeholder for moduleIsEnabled check

* [not verified] Remove isModuleEnabled property in favor of currently available WAF data

* [not verified] Remove console logging

* [not verified] Add upgrade functionality to button

* [not verified] Add Popover component for upgrade info

* Introduce and apply FirewallFooter component

* Add central AdminSection component for better visualization

* Improve spacing

* [not verified] Apply initial run at StandaloneModeModal component

* [not verified] Update Footer component to ScanFooter

* [not verified] Improve StandaloneModeModal structure and styling

* [not verified] Add FirewallFooter stories

* [not verified] Update FirewallFooter to use SeventyFiveLayout

* [not verified] Update styling comments

* Fix styling issues

* Create ConnectedFirewallHeader component and move all logic out of FirewallPage

* Improve code efficiency

* Update FirewallHeader status check, and checkout flow redirect URL

* changelog

* [not verified] Remove changelog entry

* Change FirewallUrl to firewallUrl

* Fix styling issues

Co-authored-by: Nate Weller <nate.weller@automattic.com>
…27584)

* Add upgrade prompt when WAF enabled but no rules access

* Create separate internal component for upgrade prompt

* Add story for on with no plan
* [not verified] Update WAF package to use portable Current_Plan over Jetpack_Plan for upgrade detection

* Add jetpack-plans dependency direct to the WAF package

* Add and use hasScan (over hasRulesAccess) check in Jetpack settings for the WAF module

* Remove hasRulesAccess property from WAF module component

* Remove has_rules_access method in favour of external plan checks
* [not verified] Add jetpack_waf_share_data option value to initial state, and use for checked value

* [not verified] Remove comments

* [not verified] Remove prior solution in favor of WAF endpoints solution and apply toggleShareData functionality to FirewallFooter checkbox

* [not verified] Improve share data toggle functionality

* [not verified] Improve code organization

* [not verified] Add isEnabled check for share data section display

* Remove wafShareData from initial state

Co-authored-by: Nate Weller <nate.weller@automattic.com>
@github-actions github-actions bot added [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Status] In Progress labels Nov 29, 2022
@nateweller nateweller changed the base branch from add/protect-waf-phase-2 to add/waf-automatic-rule-toggle December 16, 2022 06:02
@nateweller nateweller changed the title Protect: Add separation for automatic and manual WAF rules usage Protect: Turn on waf module by default and add UI control for automatic rules Dec 16, 2022
@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Dec 16, 2022
Base automatically changed from add/waf-automatic-rule-toggle to add/protect-waf-phase-2 December 19, 2022 19:19
@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Needs Test Review E2E Tests labels Dec 19, 2022
@dkmyta
Copy link
Contributor Author

dkmyta commented Dec 19, 2022

Looks and works great!

One minor styling issue:
Annotation on 2022-12-19 at 12-53-33

It appears that we can now remove both of the margin-left declarations associated with the .edit-manual-rules-section class in the FirewallPage component.

Copy link
Contributor

@nateweller nateweller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with/on behalf of Dean 👍

Changelog issues will be addressed in the main project branch.

@nateweller nateweller removed [Status] Needs Team Review [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Dec 19, 2022
@nateweller nateweller merged commit 3969cd5 into add/protect-waf-phase-2 Dec 19, 2022
@nateweller nateweller deleted the add/protect-waf-manual-vs-automatic-separation branch December 19, 2022 21:22
@nateweller nateweller added this to the protect/1.2.1 milestone Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Tests [Package] WAF [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Status] Needs Test Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants